<?php

namespace Apps\Weixin\Controllers;

use Apps\Common\Controller\WeixinBaseController;
use Apps\Weixin\Services\WxResourceService;

class FrontController extends WeixinBaseController
{
    public function indexAction()
    {
        exit('Welcome Service!');
    }

    public function authAction()
    {
        $url = sprintf(
            'https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s&auth_type=3',
            static::$_config->weixin->appid,
            WxResourceService::getInstance()->getPreAuthCode(),
            static::$_config->project->apibaseurl . '/weixin/event/authcallback'
        );
        echo <<<EOF
<a href="{$url}">>>第三方授权访问入口<<</a>
EOF;
    }
}
